using System.Data;
using Dapper.Abstractions;
using MySqlConnector;

namespace Dapper.MySql;

public class MySqlConnectionFactory : IDbConnectionFactory
{
    private readonly string _connectionString;

    public MySqlConnectionFactory(string connectionString)
    {
        _connectionString = connectionString ?? throw new ArgumentNullException(nameof(connectionString));
    }

    public IDbConnection CreateConnection()
    {
        return new MySqlConnection(_connectionString);
    }

    public Task<IDbConnection> CreateConnectionAsync()
    {
        return Task.FromResult<IDbConnection>(new MySqlConnection(_connectionString));
    }
}
